package com.wuad.platformwuad.module.system.controller;

import com.wuad.platformwuad.common.Result;
import com.wuad.platformwuad.module.system.entity.SysUserEntity;
import com.wuad.platformwuad.module.system.service.SysUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author wuad
 * @date 2023年08月11日 10:07
 */
@Slf4j
@RequestMapping("/sysuser")
@RestController
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    /**
     * 测试接口访问
     *
     * @return
     */
    @GetMapping("/check")
    public Result check() {
        return Result.success(200, "hello word");
    }

    /**
     * 获取用户信息
     *
     * @param id
     * @return
     */
    @GetMapping("/getUserInfo")
    public Result getSystemUserInfo(@RequestParam("id") String id) {
        SysUserEntity sysUserEntity = sysUserService.selectById(id);
        return Result.success(200, sysUserEntity);
    }

    /**
     * 获取用户列表
     *
     * @return
     */
    @GetMapping("/getAll")
    public Result getAll() {
        try {
            List<SysUserEntity> sysUserEntityList = sysUserService.getAll();
            return Result.success(200, sysUserEntityList);
        } catch (Exception e) {
            log.info("1111111:{}", e.getMessage());
            return Result.success(200);
        }
    }


}
